package cn.itrigger.dynamic.sql.condition;

import java.util.Objects;
import java.util.function.Supplier;

/**
 * 组装只有一个值的条件.如:column='aaa',column>2
 * @author admin
 * @date 2018/9/20
 **/
public abstract class AbstractSingleValueCondition<T> implements VisitableCondition<T> {

    private Supplier<T> valueSupplier;

    protected AbstractSingleValueCondition(Supplier<T> supplier) {
        this.valueSupplier = Objects.requireNonNull(supplier);
    }

    public T value() {
        return valueSupplier.get();
    }

    @Override
    public <R> R accept(ConditionVisitor<T,R> visitor) {
        return visitor.visit(this);
    }

    public abstract String renderCondition(String columnName, String placeholder);
}
